package org.redmagic.location;

import java.net.URI;
import java.util.Properties;

import javax.annotation.ParametersAreNonnullByDefault;

import org.redmagic.utils.Conditions;

@ParametersAreNonnullByDefault
public abstract class UriLocation implements Location {
	
	private final URI uri;
	
	protected UriLocation(String uri) {
		this(URI.create(uri));
	}
	
	protected UriLocation(URI uri) {
	    Conditions.notNull(uri, "uri");
	    Conditions.checkArgument(!uri.toString().isEmpty(), "uri cannot be empty.");
		this.uri = uri;
	}
	
	@Override
	public void postProcess(Properties properties) {
	    Conditions.notNull(properties, "properties");
	}
	
	public URI getURI() {
		return uri;
	}
	
	@Override
	public String toString() {
	    StringBuilder sb = new StringBuilder();
	    sb.append(getClass().getSimpleName() + "{");
	    sb.append("uri=");
	    sb.append(uri);
	    sb.append("}");
		return sb.toString();
	}
}